package com.ruoyi.web.controller.cems;

import com.ruoyi.cems.domain.BmsWorkCheckListDetailRemark;
import com.ruoyi.cems.mapper.BmsWorkCheckListDetailRemarkMapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Api(description = "工作检查单明细操作")
@RestController
@RequestMapping("/cems/detailRmark")
public class BmsWorkCheckListDetailRemarkController extends BaseController {

    @Autowired
    private BmsWorkCheckListDetailRemarkMapper bmsWorkCheckListDetailRemarkService;

    @ApiOperation(value = "查询工作检查单明细操作列表")
    @RequestMapping("/list")
    public TableDataInfo list(String detailId) {
        startPage();
        List<BmsWorkCheckListDetailRemark> list= bmsWorkCheckListDetailRemarkService.selectBmsWorkCheckListDetailRemarkListByDetailId(detailId);
        return getDataTable(list);
    }

    @ApiOperation(value = "新增工作检查单操作")
    @Log(title = "添加工作检查单明细操作", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BmsWorkCheckListDetailRemark bmsWorkCheckListDetailRemark) {
        bmsWorkCheckListDetailRemark.setID(UUID.randomUUID().toString().replace("-", ""));
        bmsWorkCheckListDetailRemark.setCreatedBy(getUserId().toString());
        bmsWorkCheckListDetailRemark.setCreatedTime(new Date());
        return toAjax(bmsWorkCheckListDetailRemarkService.insertBmsWorkCheckListDetailRemark(bmsWorkCheckListDetailRemark));
    }


    @ApiOperation(value = "修改工作检查单操作")
    @Log(title = "编辑工作检查单明细操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsWorkCheckListDetailRemark bmsWorkCheckListDetailRemark){
        bmsWorkCheckListDetailRemark.setUpdatedBy(getUserId().toString());
        bmsWorkCheckListDetailRemark.setUpdatedTime(new Date());
        return toAjax(bmsWorkCheckListDetailRemarkService.updateBmsWorkCheckListDetailRemark(bmsWorkCheckListDetailRemark));
    }
}
